package algotithm.acwing.lineardp;



import java.util.Scanner;
/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/16-23:33
 */

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = 1100;
        int[] f = new int[N];
        int[] a = new int[N];

        int n = sc.nextInt();
        for (int i = 1; i <= n ; i++) {
            a[i] = sc.nextInt();
        }

        for (int i = 1; i <= n; i++) {
            f[i] = 1;//每一个f[i]的初始化都是1，因为最短就是本身，即为1；
            for (int j = 1; j < i; j++) {
                if (a[i] > a[j]) {
                    f[i] = Math.max(f[i], f[j] + 1);
                }
            }
        }

        int res = 0; //通过遍历f数组，来求最大值

        for (int i = 1; i <= n; i++) {
            res = Math.max(res, f[i]);
        }
        System.out.println(res);
    }
}
